﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NHibernate.Mapping.Attributes;

namespace TinyERP.ERP.Entity
{
    [NHibernate.Mapping.Attributes.Class(Table="Contact", NameType = typeof(Contact), Abstract = true)]
    [NHibernate.Mapping.Attributes.Discriminator(1, Column="ContactDiscriminator", 
        NotNull=true, TypeType=typeof(string))]
    public abstract class Contact
    {
        [NHibernate.Mapping.Attributes.Id(0, TypeType = typeof(long), Column = "ID", Name = "ID")]
        [NHibernate.Mapping.Attributes.Generator(1, Class = "native")]
        public virtual long ID { get; set; }

        [NHibernate.Mapping.Attributes.Property(Column = "FirstName")]
        public virtual string FirstName { get; set; }

        [NHibernate.Mapping.Attributes.Property(Column = "LastName")]
        public virtual string LastName { get; set; }

        [NHibernate.Mapping.Attributes.Property(Column = "Title")]
        public virtual string Title { get; set; }

        [NHibernate.Mapping.Attributes.Property(Column = "Description")]
        public virtual string Description { get; set; }

        

        [NHibernate.Mapping.Attributes.Property(Column = "WebSite")]
        public virtual string WebSite { get; set; }

        [NHibernate.Mapping.Attributes.Property(Column = "Email")]
        public virtual string Email { get; set; }

        [NHibernate.Mapping.Attributes.Property(Column = "IM")]
        public virtual string IM { get; set; }

        [NHibernate.Mapping.Attributes.Property(Column = "Fax")]
        public virtual string Fax { get; set; }


        [NHibernate.Mapping.Attributes.Bag(Cascade = "all",
            Name = "PhoneList", Table = "PhoneNumber")]
        [Key(1, Column = "ContactID")]
        [OneToMany(2, ClassType = typeof(PhoneNumber))]
        public virtual IList<PhoneNumber> PhoneList { get; set; }

        [NHibernate.Mapping.Attributes.Bag(Cascade = "all",
           Name = "IMContactList", Table = "IMContact")]
        [Key(1, Column = "ContactID")]
        [OneToMany(2, ClassType = typeof(IMContact))]
        public virtual IList<IMContact> IMContactList { get; set; }

        [NHibernate.Mapping.Attributes.Bag(Cascade = "all",
            Name = "ContactAddressList", Table = "ContactAddress")]
        [Key(1, Column = "ContactID")]
        [OneToMany(2, ClassType = typeof(Address))]
        public virtual IList<Address> ContactAddressList { get; set; }
    }
}
